#include <cppunit/config/SourcePrefix.h>
#include "ASTTest.h"
#include <iostream>
#include <string>
#include <fstream>
#include <stdio.h>
#include "Parser.h"
#include "AST.h"

using namespace std;

void ASTTest::setUp() {
}

void ASTTest::tearDown() {
}

CPPUNIT_TEST_SUITE_REGISTRATION( ASTTest );

void ASTTest::testConstructor() {
	st = new StmtTable();
	vt = new VarTable();
	f = new Follows(vt,st);
	ast = new AST(st,f);
};


void ASTTest::testCreateAndLinkNodeAST() {
	PKB* pkb = new PKB();
	Parser* p = new Parser(pkb);
	DESIGN_ENTITY de1, de2, stmtLst;

	TNode* rootResult;
	TNode* parentNode = new TNode("ROOT", 0);
	TNode* stmtLstNode = new TNode("stmtLst", 3);

	cout << "Testing: TNode* AST::createAndLinkNodeAST(DESIGN_ENTITY, VALUE, TNode*)" << endl;
	
	rootResult = pkb->ast->createAndLinkNodeAST(de1,1,parentNode);
	CPPUNIT_ASSERT(rootResult->val == 1);

	TNode* stmtLstResult = pkb->ast->createAndLinkNodeAST(de2,2,stmtLstNode);
	CPPUNIT_ASSERT(stmtLstResult->val == 2);

	cout << "Test OK: TNode* AST::createAndLinkNodeAST(DESIGN_ENTITY, VALUE, TNode*)" << endl;
};

